package com.serverTechnology.craft.mapper;

import com.serverTechnology.craft.entity.StepsParameter;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.serverTechnology.craft.entity.dto.StandardParameterDto;
import com.serverTechnology.craft.entity.vo.StepsParameterVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 工步所需要的参数 Mapper 接口
 * </p>
 *
 * @author 王烁
 * @since 2024-08-01
 */
public interface StepsParameterMapper extends BaseMapper<StepsParameter> {

    @Select("SELECT \n" +
            " tsp.ID AS id,\n" +
            " td.DEVICE_NAME AS deviceName,\n" +
            " tdd.DISPOSITION_NAME AS dispositionName,\n" +
            " tsp.MAX_VALUE AS minValue,\n" +
            " tsp.MIN_VALUE AS maxValue,\n" +
            " tsp.NOMINAL_VALUE AS nominalValue\n" +
            "FROM\n" +
            "TE_STEPS_RESOURCE_TYPE tsrt\n" +
            "LEFT JOIN TE_STEPS_PARAMETER tsp ON tsrt.id = tsp.STEPS_RESOURCE_TYPE_ID\n" +
            "LEFT JOIN TE_DEVICE td ON tsrt.DEVICE_ID = td.ID\n" +
            "LEFT JOIN TE_DISPOSITION tdd ON tdd.ID = tsp.DISPOSITION_ID\n" +
            "WHERE\n" +
            "tsrt.PROCESS_STEPS_ID = #{stepsResourceTypeId}\n" +
            "AND tsrt.DEVICE_DISTINGUISH = #{deviceDistinguish}\n" +
            "AND td.DEVICE_STATE = #{deviceState}")
    List<StepsParameterVo> getstepsParameterIdAnd(StandardParameterDto standardParameterDto);

}
